<?php
require_once 'MTransition.php';
require_once 'MTransitionCollection.php';

class MState{

	public $id;
	public $title;
	public $desc;
	private $transColl;

	public function __construct($id, $title){
		if(!is_string($id) || !is_string($title)) throw new MWorkFlowException("$id and $title MUST be a string.");

		$this->id = $id;
		$this->title = $title;
		$this->transColl = new MTransitionCollection();
	}

	public function setTransitions(MTransitionCollection $transitions){
		$this->transColl = $transitions;
	}
	public function addTransition(MTransition $transition){

		$oldAmount = $this->transColl->size();
		$this->transColl[$transition->id] = $transition;
		//var_dump($this->stateColl);
		if($this->transColl->size()== $oldAmount+1)
			return true;
		else
			return false;
	}
	public function removeTransition($id){
		if(array_key_exists($id, $this->transColl->objectArray)){
			unset($this->transColl->objectArray[$id]);
			return true;
		} else {
			return false;
		}
	}
	public function possibleTransitions(){}
	private function getTransitions(){ return $this->transColl;}

}
?>